///
/// 张诚宇
///
/// 新闻列表首页
///
///2022.6.14
///

import 'package:flutter/material.dart';
import 'package:zhangchengyu20220614/view/news_one_fragment.dart';
import 'package:zhangchengyu20220614/view/videopage.dart';

class NewsHomePage extends StatefulWidget {
  const NewsHomePage({Key key}) : super(key: key);

  @override
  _NewsHomePageState createState() => _NewsHomePageState();
}

class _NewsHomePageState extends State<NewsHomePage> with SingleTickerProviderStateMixin{

  TabController _tabController;
  List<Widget> _list;
  List<Widget> _children;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    _list=[
      Text("要闻"),
      Text("推荐"),
      Text("热榜"),
      Text("抗疫"),
      Text("视频"),
      Text("娱乐"),
      Text("有料"),
      Text("军事"),
      Text("经济"),
    ];
    _children=[
      Container(child: Text('要闻'),),
      NewsOneFragment(),
      Container(child: Text('热榜'),),
      Container(child: Text('抗疫'),),
      VideoPage(),
      Container(child: Text('娱乐'),),
      Container(child: Text('有料'),),
      Container(child: Text('军事'),),
      Container(child: Text('经济'),),
    ];
    _tabController=TabController(length: _list.length, vsync: this);
  }


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: TextField(
          decoration: InputDecoration(
            filled: true,
            fillColor: Colors.white,
            border: OutlineInputBorder(
              borderRadius: BorderRadius.circular(8),
            ),
            prefixIcon: Icon(Icons.search),
          ),
        ),
      ),
      body: Column(
        children: [
          Container(
              color: Colors.white,
              child: TabBar(
                labelColor: Colors.black,
                unselectedLabelColor: Colors.grey,
                tabs: _list,controller: _tabController,isScrollable: true,)),
          Expanded(child: TabBarView(controller: _tabController,children: _children,))
        ],
      ),
    );
  }
}
